package com.pan.common.barrier.filter;

import lombok.extern.slf4j.Slf4j;
import org.springframework.core.Ordered;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 *
 * order注解并不生效
 * @author by panstark
 * @description
 * @notice
 * @date 2020/11/27
 */
@Slf4j
//@WebFilter(urlPatterns = {"/*"}, filterName = "secondfilter")
public class SecondFilter implements Filter , Ordered {
    @Override
    public void init(FilterConfig filterConfig){
      log.info("--------second filter init---------------------");
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {
        log.info("--------second filter doFilter start---------------------");
        //注意，一定要写dofilter方法，否则过滤将中断于此。
        filterChain.doFilter(request, response);
        log.info("--------second filter doFilter completed---------------------");
    }

    @Override
    public void destroy() {
        log.info("--------second filter destroy---------------------");
    }

    @Override
    public int getOrder() {
        return 1;
    }

}
